package gamecode;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Input;
import org.newdawn.slick.geom.Rectangle;

public class EntityPlayerShip extends Entity {
	
	private final float rotSpeed = 0.2f;
	private final float accelSpeed = 0.0005f;
	private boolean ForwardPressed = false;

	public EntityPlayerShip(Image simage, Color scolor) {
		this.setVelocity(0, 0);
		this.setPosition(0, 0);
		this.setImage(simage);
		this.setColor(scolor);
		isPlayerShip = true;
	}
	
	public void checkInput(Input input, int delta) {
		if(input.isKeyDown(Input.KEY_A)) {
			this.rotate(-rotSpeed * delta);
		}
		if(input.isKeyDown(Input.KEY_D)) {
			this.rotate(rotSpeed * delta);
		}
		if(input.isKeyDown(Input.KEY_W)) {
			this.setAcceleration(this.getDirection(), accelSpeed);
			ForwardPressed = true;
		}
		if(!input.isKeyDown(Input.KEY_W) && ForwardPressed) {
			this.setAcceleration(this.getDirection(), 0);
		}
	}
	
	public void drawShip(Graphics g, Rectangle bounds) {
		g.drawImage(this.getImage(), bounds.getCenterX(), bounds.getCenterY(), this.getColor());
	}
}
